//
//  ViewController.m
//  niminban
//
//  Created by zhouteng on 16/9/30.
//  Copyright © 2016年 zhouteng. All rights reserved.
//

#import "ViewController.h"
#import "URLS.h"
#import "AFNetworking.h"
#import "ForumGroup.h"
#import "MJExtension.h"
#import "Title.h"
#import "Thread.h"


@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    [self getForumList];
    [self showF];
    [self getThread];
}

-(void)getForumList{
    NSString *URLString = GET_FORUM_LIST;
    NSLog(GET_FORUM_LIST);
    AFHTTPSessionManager *magager = [AFHTTPSessionManager manager];
    
    magager.responseSerializer = [AFJSONResponseSerializer serializer  ];
    
    [magager GET:URLString parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {

        NSArray <ForumGroup *> *fg = [ForumGroup mj_objectArrayWithKeyValuesArray:responseObject];
        NSLog(@"%@",fg);
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        NSLog(@"error");
    }];
}

-(void)showF{
    NSString *URLString = GET_F;
    NSLog(GET_F);
    AFHTTPSessionManager *magager = [AFHTTPSessionManager manager];
    
    magager.responseSerializer = [AFJSONResponseSerializer serializer  ];
    
    [magager GET:URLString parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
        NSArray <Title *> *tg = [Title mj_objectArrayWithKeyValuesArray:responseObject];
        NSLog(@"%@",tg);
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        NSLog(@"error");
    }];
}

-(void)getThread{
    NSString *URLString = GET_THREAD;
    NSLog(GET_THREAD);
    AFHTTPSessionManager *magager = [AFHTTPSessionManager manager];
    
    magager.responseSerializer = [AFJSONResponseSerializer serializer  ];
    
    NSDictionary *parameters = @{@"id":@"6467841"};
    
    [magager GET:URLString parameters:parameters progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
        Thread *thread = [Thread mj_objectWithKeyValues:responseObject];
        
        NSLog(@"%@",thread);
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        NSLog(@"error");
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end



